package com.vayne.injectdemo;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * @author xuerui.zhang
 * @since 2020/4/13 下午9:22
 */
public class XMLSetterInjectionDemo {

    public static void main(String[] args) {
        // 创建应用上下文：BeanFactory 容器
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
        // 加载资源
        XmlBeanDefinitionReader beanDefinition = new XmlBeanDefinitionReader(beanFactory);
        String path = "classpath:/dependency_setter_injection.xml";
        beanDefinition.loadBeanDefinitions(path);

        CourseHolder courseHolder = beanFactory.getBean(CourseHolder.class);
        System.out.println(courseHolder.getCourse());
    }
}
